class Solution(object):
    def wateringPlants(self, plants, capacity):
        ans = 0
        now = 0
        n = len(plants)
        index = 0
        while index < n:
            now += plants[index]
            if now <= capacity:
                ans += 1
            else:
                now = plants[index]
                ans += 2 * index + 1
            index += 1
        return ans

